package com.lxy.demo.controller;

import com.lxy.demo.entity.UserEntity;
import com.lxy.demo.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Administrator
 */
@Controller
@RequestMapping("/user")
public class ShowAllUserController {
    @Resource
    private UserService userService;

    /**
     * 对应SpringMVC返回JSON
      */
    @ResponseBody
    @RequestMapping("/list")
    public List<UserEntity> queryUserList() {
        List<UserEntity> list = userService.queryUserList();

        for (UserEntity entity : list) {
            if (entity.getUserId() == 5) {
                System.out.println(entity);
            }
        }

        return list;
    }
}






